package com.imay.live.adapter;



import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import com.imay.live.model.RechargeInfoModel;

import com.imay.live.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by liangzhenxiong on 2017/4/6 0006.
 * 充值记录
 */

public class PutMonenyLinearAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

    private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public final static int VIEWTYPE_LINEAR_TITLE = 0x1112;//名人标题


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public PutMonenyLinearAdapter(List<MultiItemEntity> data) {
        super(data);
        addItemType(VIEWTYPE_LINEAR_TITLE, R.layout.item_putmoneny);

    }


    @Override
    protected void convert(final BaseViewHolder helper, MultiItemEntity item) {
        if (item.getItemType() == VIEWTYPE_LINEAR_TITLE) {
            if (item instanceof RechargeInfoModel) {
                RechargeInfoModel rechargeInfoModel = (RechargeInfoModel) item;

                helper.setText(R.id.tv_des, helper.getConvertView().getResources().getString(R.string.rechargemeizuan, rechargeInfoModel.getDiamond()));
                ;
                Date currentTime;
                try {
                    currentTime = new Date(rechargeInfoModel.getTimeRecharge() * 1000L);
                } catch (Exception e) {
                    currentTime = new Date();
                }
                String dateString = formatter.format(currentTime);
                helper.setText(R.id.tv_time, dateString);
            }

        }


    }
}
